﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
   public  class NhanVien_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_NhanVien");
       }
       public DataTable Load_TimKiem_NhanVien()
       {
           return kn.LayDuLieu("Load_TimKiem_NhanVien");
       }

       public DataTable DangNhap_QuanLy(NhanVien_Public tenDangNhap, NhanVien_Public matKhau)
       {
           int n = 2;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@TenDangNhap";
           value[0] = tenDangNhap.TenDangNhap;
           name[1] = "@MatKhau";
           value[1] = matKhau.MatKhau;
           return kn.LayDuLieu("DangNhap_QuanLy",name,value,n);
       }
       public DataTable DangNhap_NhanVien(NhanVien_Public tenDangNhap, NhanVien_Public matKhau)
       {
           int n = 2;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@TenDangNhap";
           value[0] = tenDangNhap.TenDangNhap;
           name[1] = "@MatKhau";
           value[1] = matKhau.MatKhau;
           return kn.LayDuLieu("DangNhap_NhanVien", name, value, n);
       }
       public int DoiMatKhau(NhanVien_Public tenDangNhap, NhanVien_Public matKhau)
       {
           int n = 2;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@TenDangNhap";
           value[0] = tenDangNhap.TenDangNhap;
           name[1] = "@MatKhau";
           value[1] = matKhau.MatKhau;
           return kn.update("DoiMatKhau", name, value, n);
       }
       public DataTable TimKiem_MaNV(NhanVien_Public maNV)
       {
           int n = 1;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@MaNV";
           value[0] = maNV.MaNV;
           return kn.LayDuLieu("TimKiem_MaNV", name, value, n);
       }
       public DataTable TimKiem_HoTen(NhanVien_Public hoTen)
       {
           int n = 1;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@HoTen";
           value[0] = hoTen.HoTen;
           return kn.LayDuLieu("TimKiem_HoTen", name, value, n);
       }
       public DataTable TimKiem_MaNV_HoTen(NhanVien_Public maNV, NhanVien_Public hoTen)
       {
           int n = 2;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@MaNV";
           value[0] = maNV.MaNV;
           name[1] = "@HoTen";
           value[1] = hoTen.HoTen;
           return kn.LayDuLieu("TimKiem_MaNV_HoTen", name, value, n);
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taoBang(sql);
       }
       public int Insert_NhanVien(NhanVien_Public hoTen, NhanVien_Public ngaySinh, NhanVien_Public gioiTinh, NhanVien_Public cMT, NhanVien_Public diaChi, NhanVien_Public dienThoai, NhanVien_Public email, NhanVien_Public maNQ,NhanVien_Public tenDangNhap, NhanVien_Public matKhau)
       {
           int Nparameter = 10;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@HoTen";
           value[0] = hoTen.HoTen;
           name[1] = "@NgaySinh";
           value[1] = ngaySinh.NgaySinh;
           name[2] = "@GioiTinh";
           value[2] = gioiTinh.GioiTinh;
           name[3] = "@CMT";
           value[3] = cMT.CMT;
           name[4] = "@DiaChi";
           value[4] = diaChi.DiaChi;
           name[5] = "@DienThoai";
           value[5] = dienThoai.DienThoai;
           name[6] = "@Email";
           value[6] = email.Email;
           name[7] = "@MaNQ";
           value[7] = maNQ.MaNQ;
           name[8] = "@TenDangNhap";
           value[8] = tenDangNhap.TenDangNhap;
           name[9] = "@MatKhau";
           value[9] = matKhau.MatKhau;
           return kn.update("insert_NhanVien", name, value, Nparameter);
       }
       public int Update_NhanVien(NhanVien_Public maNV, NhanVien_Public hoTen, NhanVien_Public ngaySinh, NhanVien_Public gioiTinh, NhanVien_Public cMT, NhanVien_Public diaChi, NhanVien_Public dienThoai, NhanVien_Public email, NhanVien_Public maNQ, NhanVien_Public tenDangNhap, NhanVien_Public matKhau)
       {
           int Nparameter = 11;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaNV";
           value[0] = maNV.MaNV;
           name[1] = "@HoTen";
           value[1] = hoTen.HoTen;
           name[2] = "@NgaySinh";
           value[2] = ngaySinh.NgaySinh;
           name[3] = "@GioiTinh";
           value[3] = gioiTinh.GioiTinh;
           name[4] = "@CMT";
           value[4] = cMT.CMT;
           name[5] = "@DiaChi";
           value[5] = diaChi.DiaChi;
           name[6] = "@DienThoai";
           value[6] = dienThoai.DienThoai;
           name[7] = "@Email";
           value[7] = email.Email;
           name[8] = "@MaNQ";
           value[8] = maNQ.MaNQ;
           name[9] = "@TenDangNhap";
           value[9] = tenDangNhap.TenDangNhap;
           name[10] = "@MatKhau";
           value[10] = matKhau.MatKhau;
           return kn.update("update_NhanVien", name, value, Nparameter);
       }
       public int Delete_NhanVien(NhanVien_Public maNV)
       {
           int Nparameter = 1;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaNV";
           value[0] = maNV.MaNV;
           return kn.update("delete_NhanVien", name, value, Nparameter);
       }

    }
}
